package display;

import java.awt.Color;
import java.awt.Point;
import java.util.ArrayList;

public class Utils {

	public static boolean DISPLAY_CLONE = true;

	public static int sideWidth = 15; //taille en pixel d'un carré
	public static int sideWidthMini = 8; //taille en pixel d'un mini carré
	public static int bordureFrameWidth = 20;
	public static int bordureFrameHeight = 50;

	public static int bordureBlockSelected = 2;

	public static int paddingFrame = 50;
	public static int paddingMiniBlock = 5;

	public static int getNextBlockDisplayWidthPx = (getBlockWidthPx() * 3) / 2;
	public static int getNextBlockDisplayHeightPx = (getBlockHeightPx() * 3) / 2;

	public static int getMiniBlockDisplayWidthPx = (sideWidthMini * universe.Utils.getBlockWidth() * 3) / 2;
	public static int getMiniBlockDisplayHeightPx = (sideWidthMini * universe.Utils.getBlockHeight() * 3) / 2;

	public static int gameDisplayWidth = getBoardWidthPx()+bordureFrameWidth+paddingFrame;
	public static int gameDisplayHeight = getBoardHeightPx()+bordureFrameHeight+(paddingFrame*2);

	public static int gameDataDisplayWidth = getNextBlockDisplayWidthPx+(Utils.paddingFrame*2);
	public static int gameDataDisplayHeight = gameDisplayHeight;
	
	public static Color soundBoxHomeMenuColor = Color.WHITE;
	public static Color soundBoxHomeMenuFontColor = Color.BLACK;
	public static int   soundBoxHomeMenuAlpha = 0;
	
	public static Color boardColor = Color.DARK_GRAY;
	public static int 	boardAlpha = 200;
	public static Color nextBlockDisplayColor = boardColor;
	public static int	nextBlockDisplayAlpha = boardAlpha;
	public static Color gameDataDisplayColor  = boardColor;
	public static int	gameDataDisplayAlpha = boardAlpha;
	
	public static Color gameDataDisplayFontColor = Color.white;
	
	public static String iconFrameImage = "resources/icone-tetris.png";
	public static String homeMenuBackgroundImage = "resources/tetris3.jpg";
	public static String topScoresImage = "resources/end.jpg";
	public static String gameBackgroundImage = "resources/miroirdo.jpg";
	
	public static Color pauseBackgroundColor = new Color(0, 102, 102);
	public static int 	pauseAlpha = 120;
	public static Color pauseTextColor = Color.BLACK;
	
	
	public static Color[] basique = {Color.RED,Color.CYAN,Color.GREEN,Color.BLUE,Color.PINK,new Color(127, 255, 0),Color.MAGENTA};
	public static Color[] construction = {new Color(102, 0, 0),new Color(102, 0, 0),new Color(102, 0, 0),new Color(102, 0, 0),new Color(102, 0, 0),new Color(102, 0, 0),new Color(102, 0, 0)};

	public static int getBoardWidthPx(){
		return universe.Utils.getBoardWidth()*sideWidth;
	}

	public static int getBoardHeightPx(){
		return universe.Utils.getBoardHeight()*sideWidth;
	}


	public static int getBlockWidthPx(){
		return universe.Utils.getBlockWidth()*sideWidth;
	}

	public static int getBlockHeightPx(){
		return universe.Utils.getBlockHeight()*sideWidth;
	}

	public static int getFrameWidthPx(){
		return gameDisplayWidth+gameDataDisplayWidth;
	}

	public static int getFrameHeightPx(){
		return gameDisplayHeight;
	}


	/*public static Color getCloneColor(){
		//return new Color(230,230,230);
		return Color.red;
	}*/
	
	public static final int cloneAlpha = 64;	


	
	
	/*public static Color currentColorBlockA = Color.RED;
	public static Color currentColorBlockB = Color.CYAN;
	public static Color currentColorBlockC = Color.GREEN;
	public static Color currentColorBlockD = Color.BLUE;
	public static Color currentColorBlockE = Color.PINK;
	public static Color currentColorBlockF = new Color(127, 255, 0);
	public static Color currentColorBlockG = Color.MAGENTA;*/
	
	
	/*
	private static ArrayList<Theme> themes;
	
	
	private static Theme currentTheme;
	
	public static Theme getCurrentTheme(){
		if(currentTheme == null){
			
			System.out.println("OWNED");
			currentTheme = new Theme();
			currentTheme.setColorBlockA(Color.RED);
			currentTheme.setColorBlockB(Color.CYAN);
			currentTheme.setColorBlockC(Color.GREEN);
			currentTheme.setColorBlockD(Color.BLUE);
			currentTheme.setColorBlockE(Color.PINK);
			currentTheme.setColorBlockF(new Color(127, 255, 0));
			currentTheme.setColorBlockG(Color.MAGENTA);
			currentTheme.setName("Basique");
		}
		return currentTheme;
	
	}
	
	public static void setCurrentTheme(Theme pTheme){
		System.out.println("Theme changé");
		currentTheme = pTheme;
	}
*/
	
	
	
	
	
	
	
	
	public static int colorGameOver = 9;
	public static int colorGameOverBackground = 1;


	public static Color getColor(int pInt){
		Color returnedColor;
	
		switch (pInt){
			case 1 : returnedColor = Color.ORANGE; break;
			case 2 : returnedColor = application.Utils.getCurrentTheme().getColorBlockA();  break;
			case 3 : returnedColor = application.Utils.getCurrentTheme().getColorBlockB() ; break;
			case 4 : returnedColor = application.Utils.getCurrentTheme().getColorBlockC() ; break;
			case 5 : returnedColor = application.Utils.getCurrentTheme().getColorBlockD() ; break;
			case 6 : returnedColor = application.Utils.getCurrentTheme().getColorBlockE() ; break;
			case 7 : returnedColor = application.Utils.getCurrentTheme().getColorBlockF();  break;
			case 8 : returnedColor = application.Utils.getCurrentTheme().getColorBlockG() ;  break;
			case 9 : returnedColor = Color.RED ; break; 
			default : returnedColor= Color.WHITE ;
		}

		return returnedColor;
	}


	
	/*public static int getColorNumber(Color pColor){
		int returnedInt;
		
		if(pColor == Color.ORANGE){
			returnedInt = 1; 
		}
		else if(pColor == colorBlockA){
			returnedInt = 2;
		}
		else if(pColor == colorBlockB){
			returnedInt = 3;
		}
		else if(pColor == colorBlockC){
			returnedInt = 4;
		}
		else if(pColor == colorBlockD){
			returnedInt = 5;
		}
		else if(pColor == colorBlockE){
			returnedInt = 6;
		}
		else if(pColor == colorBlockF){
			returnedInt = 7;
		}
		else if(pColor == colorBlockG){
			returnedInt = 8;
		}
		else{
			returnedInt = 0 ;
		}
		return returnedInt;
	}*/
	
	
	public static ArrayList<Point> getGameOverLocation(){

		ArrayList<Point> gameOverLocation = new ArrayList<Point>();
		
		//G
		gameOverLocation.add(new Point(0,3));
		gameOverLocation.add(new Point(0,4));
		gameOverLocation.add(new Point(0,5));
		gameOverLocation.add(new Point(0,6));
		gameOverLocation.add(new Point(0,7));
		gameOverLocation.add(new Point(1,3));
		gameOverLocation.add(new Point(1,7));
		gameOverLocation.add(new Point(2,3));
		gameOverLocation.add(new Point(2,5));
		gameOverLocation.add(new Point(2,6));
		gameOverLocation.add(new Point(2,7));
		
		//A
		gameOverLocation.add(new Point(4,3));
		gameOverLocation.add(new Point(4,4));
		gameOverLocation.add(new Point(4,5));
		gameOverLocation.add(new Point(4,6));
		gameOverLocation.add(new Point(4,7));
		gameOverLocation.add(new Point(5,3));
		gameOverLocation.add(new Point(5,5));
		gameOverLocation.add(new Point(6,3));
		gameOverLocation.add(new Point(6,4));
		gameOverLocation.add(new Point(6,5));
		gameOverLocation.add(new Point(6,6));
		gameOverLocation.add(new Point(6,7));
		
		//M
		gameOverLocation.add(new Point(8,3));
		gameOverLocation.add(new Point(8,4));
		gameOverLocation.add(new Point(8,5));
		gameOverLocation.add(new Point(8,6));
		gameOverLocation.add(new Point(8,7));
		gameOverLocation.add(new Point(9,4));
		gameOverLocation.add(new Point(9,5));
		gameOverLocation.add(new Point(10,3));
		gameOverLocation.add(new Point(10,4));
		gameOverLocation.add(new Point(10,5));
		gameOverLocation.add(new Point(10,6));
		gameOverLocation.add(new Point(10,7));
		
		//E
		gameOverLocation.add(new Point(12,3));
		gameOverLocation.add(new Point(12,4));
		gameOverLocation.add(new Point(12,5));
		gameOverLocation.add(new Point(12,6));
		gameOverLocation.add(new Point(12,7));
		gameOverLocation.add(new Point(13,3));
		gameOverLocation.add(new Point(13,5));
		gameOverLocation.add(new Point(13,7));
		
		//O
		gameOverLocation.add(new Point(0,11));
		gameOverLocation.add(new Point(0,12));
		gameOverLocation.add(new Point(0,13));
		gameOverLocation.add(new Point(0,14));
		gameOverLocation.add(new Point(0,15));
		gameOverLocation.add(new Point(1,11));
		gameOverLocation.add(new Point(1,15));
		gameOverLocation.add(new Point(2,11));
		gameOverLocation.add(new Point(2,12));
		gameOverLocation.add(new Point(2,13));
		gameOverLocation.add(new Point(2,14));
		gameOverLocation.add(new Point(2,15));
		
		//V
		gameOverLocation.add(new Point(4,11));
		gameOverLocation.add(new Point(4,12));
		gameOverLocation.add(new Point(4,13));
		gameOverLocation.add(new Point(4,14));
		gameOverLocation.add(new Point(5,15));
		gameOverLocation.add(new Point(6,11));
		gameOverLocation.add(new Point(6,12));
		gameOverLocation.add(new Point(6,13));
		gameOverLocation.add(new Point(6,14));
		
		//E
		gameOverLocation.add(new Point(8,11));
		gameOverLocation.add(new Point(8,12));
		gameOverLocation.add(new Point(8,13));
		gameOverLocation.add(new Point(8,14));
		gameOverLocation.add(new Point(8,15));
		gameOverLocation.add(new Point(9,11));
		gameOverLocation.add(new Point(9,13));
		gameOverLocation.add(new Point(9,15));
		
		//R
		gameOverLocation.add(new Point(11,11));
		gameOverLocation.add(new Point(11,12));
		gameOverLocation.add(new Point(11,13));
		gameOverLocation.add(new Point(11,14));
		gameOverLocation.add(new Point(11,15));
		gameOverLocation.add(new Point(12,11));
		gameOverLocation.add(new Point(12,13));
		gameOverLocation.add(new Point(12,14));
		gameOverLocation.add(new Point(13,11));
		gameOverLocation.add(new Point(13,12));
		gameOverLocation.add(new Point(13,13));
		gameOverLocation.add(new Point(13,15));
		
		return gameOverLocation;
	}

}
